package com.sean.common.page;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.sean.common.exception.DaoException;

/**
 * 分页查询参数基础类.
 * @author XinWang
 *
 */
public class Pagination implements Serializable{

	private static final long serialVersionUID = -6579435031214235862L;

	protected int pageSize = 0;// 每页记录数
	
	protected int pageNum;// 当前页数
	
	protected Map<String, Object> paramMap;
		
	public void putParams(Map<String, Object> paramMap) {
	    this.paramMap = paramMap;
	}
	
	public void putParams(Object...params) {
	    if(params == null || params.length == 0 || params.length%2 != 0) {
		throw new DaoException("查询参数设置失败，查询参数需要Key、Value对应。");
	    } else {
		for (int i = 0; i < params.length; i+=2) {
		    paramMap.put((String)params[i], params[i+1]);
		}
	    }
	}
	
	public void putParam(String key, Object value) {
	    if(this.paramMap == null) {
		this.paramMap = new HashMap<String, Object>();
	    }
	    paramMap.put(key, value);
	}

	public int getPageSize() {
	    return pageSize;
	}

	public void setPageSize(int pageSize) {
	    this.pageSize = pageSize;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public Map<String, Object> getParamMap() {
	    return paramMap;
	}

	public void setParamMap(Map<String, Object> paramMap) {
	    this.paramMap = paramMap;
	}
}
